package com.hippo4j.plugin.impl;

public class TaskTimeOutNotifyAlarmPlugin extends AbstractTaskTimerPlugin {

    public static final String PLUGIN_NAME = "task-timeout-notify-alarm-plugin";

    private long timeout;

    public TaskTimeOutNotifyAlarmPlugin(int timeout) {
        this.timeout = timeout;
    }

    @Override
    public String getPluginId() {
        return PLUGIN_NAME;
    }

    @Override
    protected void processTimeCost(long timeCost) {
        if (timeCost > timeout) {
            throw new RuntimeException("任务执行超时了");
        }
    }
}
